﻿using System;

namespace CommonFoundation.DataModel
{
    [Serializable]
    public class Schedule
    {
        public string Location
        {
            get;
            set;
        }

        private string time = String.Empty;

        public string Time
        {
            get
            {
                return this.time;
            }
            set
            {
                this.time = value.Trim();

                int pos = this.time.IndexOf('-');

                this.startTime = int.Parse( this.time.Substring(0, pos));

                this.endTime = int.Parse(this.time.Substring(pos + 1, this.time.Length - pos - 2));
            }
        }

        private int startTime = 0;

        public int StartTime
        {
            get
            {
                return this.startTime;
            }
        }

        private int endTime = 0;

        public int EndTime
        {
            get
            {
                return this.endTime;
            }
        }

        public string Period
        {
            get;
            set;
        }

        public string Weeks
        {
            get
            {
                return this.weeks;
            }
            set
            {
                this.weeks = value.Trim();

                int pos = this.weeks.IndexOf('-');

                this.startWeek = int.Parse(this.weeks.Substring(0, pos));

                this.endWeek = int.Parse(this.weeks.Substring(pos + 1, this.weeks.Length - pos - 2));
            }
        }

        private string weeks = String.Empty;

        private int startWeek = 0;

        public int StartWeek
        {
            get
            {
                return this.startWeek;
            }
        }

        private int endWeek = 0;

        public int EndWeek
        {
            get
            {
                return this.endWeek;
            }
        }

        public int WeekDay
        {
            get;
            set;
        }

        public bool IsInClass(int weekday, int time)
        {
            if (weekday == this.WeekDay && time >= this.startTime && time <= this.endTime)
            {
                return true;
            }

            return false;
        }

    }
}
